﻿using System;
using System.Text;

using mfRCF.Core.Extensions;

namespace mfRCF.Core
{
    public abstract class mfRcfCommand
    {
        #region Consts

        private const string C_STR_DEFAULT_CONTENT_TYPE = "text/xml";

        #endregion

        #region CTOR

        public mfRcfCommand(string httpPath, mfHttpMethod httpMethod)
        {
            HttpPath = httpPath.ToLower().RemoveLastSlash();
            HttpMethod = httpMethod;

            Name = "(" + HttpMethod + ") " + HttpPath;

            ContentTypeIn = C_STR_DEFAULT_CONTENT_TYPE;
            ContentTypeOut = C_STR_DEFAULT_CONTENT_TYPE; 
        }

        #endregion

        #region Properties

        public string Name
        {
            get;
            protected set;
        }

        public string HttpPath
        {
            get;
            set;
        }

        public string ContentTypeIn
        {
            get;
            set;
        }

        public string ContentTypeOut
        {
            get;
            set;
        }

        public  mfHttpMethod HttpMethod
        {
            get;
            private set;
        }
        #endregion

        #region Methods

        public abstract void ExecuteCommand(mfIHttpContext httpContext);

        public override string ToString()
        {
            return this.GetType() + " Name: " + Name;
        }

        #endregion
    }
}
